{extend name="admin@main"}

{block name="content"}

<form class="layui-card layui-form">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">Type<br><span class="nowrap color-desc">对接方式</span></label>
            <div class="layui-input-block">
                {foreach ['api'=>'公众号平台API模式','thr'=>'第三方平台授权模式','test'=>'接口功能测试'] as $k=>$v}
                <input type="radio" data-wechat-type="{$k}" name="wechat_type" value="{$k}" title="{$v}" lay-filter="wechat_type">
                {/foreach}
                <p class="help-block">请选择微信对接方式，其中第三方平台授权需要微信开放平台支持，同时需要搭建 SERVICE 服务！</p>
            </div>
        </div>
    </div>
</form>

<div data-type="api">{include file='config/options_api'}</div>
<div data-type="thr">{include file='config/options_thr'}</div>
<div data-type="test">{include file='config/options_help'}</div>

{/block}

{block name='script'}
<script>
    $(function () {
        apply('{:sysconf("wechat_type")}');
        window.form.render();
        window.form.on('radio(wechat_type)', function (data) {
            apply(data.value);
        });

        function apply(value) {
            var $active = $("[data-wechat-type='" + value + "']").trigger('click');
            if ($active.size() < 1) $("[data-wechat-type]:first").trigger('click');
            $('[data-type="' + value + '"]').show().siblings('[data-type]').hide();
        }
    });
</script>
{/block}
